<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/14-Promise.all.race.js"></script>
</head>

<body>
    <script>
        // var p1 = new Promise((resolve, reject) => {
        //     setTimeout(() => {
        //         reject('p1');
        //     }, 1500);
        // })
        // var p2 = new Promise((resolve, reject) => {
        //     setTimeout(() => {
        //         resolve('p2');
        //     }, 2000);
        // })
        // var p3 = Promise.resolve('p3');

        // let res = Promise.all([p1, p2, p3]);
        // console.log(res);

        var p1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                reject('p1');
            }, 1500);
        })
        var p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('p2');
            }, 2000);
        })
        var p3 = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('p3');
            }, 2000);
        })
        
        let res = Promise.race([p1,p2,p3])
        console.log('res: ', res);

    </script>
</body>

</html>